<?php
$form = $this->beginWidget('CActiveForm', array(
    'id'    => 'gocanh-form',
    'focus' => array($model, 'title'),
    'errorMessageCssClass' => 'error',
    'htmlOptions'          => array(
        'class'   => 'form',
    ),
));

echo $form->hiddenField($model, 'folder_id');
?>

<fieldset>
    <ul>
        <li>
            <?php echo $form->labelEx($model, 'type_id', array('class' => 'desc')); ?>

            <div>
                <?php
                $data = DNewsletterType::model()->getMenu(true);
                $attr = 'type_id';

                $this->widget('ArrayToDropDownList', array(
                    'model'         => $model,
                    'attribute'     => $attr,
                    'data'          => $data,
                    'parentId'      => 3, //goc anh
                    'disableParent' => true,
                    'selected'      => $model->getAttribute('type_id'),
                    'htmlOptions'   => array(
                        'class' => 'select',
                    ),
                ));
                ?>
            </div>
        </li>

        <li>
            <?php
            $attr = 'title';
            echo $form->labelEx($model, $attr, array('class' => 'desc'));
            ?>

            <div>
                <?php
                echo $form->textField($model, $attr, array(
                    'class' => 'text large',
                ));

                $attr = 'activated_flag';
                echo $form->checkbox($model, $attr, array(
                    'style' => 'display:inline-block;',
                ));
                echo CHtml::label($model->getAttributeLabel($attr), 'DNewsletterContent_activated_flag', array(
                    'style' => 'display:inline-block; font-weight:900;',
                    'class' => 'desc',
                ));

                echo $form->error($model, 'title');
                ?>
            </div>
        </li>

        <li>
            <?php
            $attr = 'description';
            echo $form->labelEx($model, $attr, array('class' => 'desc'));
            ?>

            <div>
                <?php
                $this->widget('ext.ckeditor.CKEditorWidget', array(
                    'model'     => $model,
                    'attribute' => $attr,
                    'config'    => array(
                        'height'   => 100,
                    ),
                ));

                echo $form->error($model, $attr);
                ?>
            </div>
        </li>
        
        <li>
            <?php
            $attr = 'images';
            echo $form->labelEx($model, $attr, array('class' => 'desc'));
            ?>

            <div>
            <?php
            $folderConfig = $model->params;
            $folderConfig['base_path'] = $folderConfig['elfinder']['base_path'] . $model->folder_id . '/';
            $folderConfig['base_url'] = $folderConfig['elfinder']['base_url'] . $model->folder_id . '/';

            $this->widget('ext.mylib.widgets.FilePicker.FilePickerWidget', array(
                'config'    => $folderConfig,
                'model'     => $model,
                'attribute' => $attr,
            ));
            echo $form->error($model, $attr);
            ?>
            </div>
        </li>

        <li style="text-align: center;">
            <?php
            echo CHtml::submitButton($model->isNewRecord ? 'CREATE' : 'SAVE', array(
                'class' => 'ui-state-default ui-corner-all ui-button'
            ));
            echo CHtml::button('RESET', array(
                'id'    => 'btn-reset',
                'class' => 'ui-state-default ui-corner-all ui-button',
                'style' => 'margin:0 10px;',
            ));
            echo CHtml::button('CANCEL', array(
                'class' => 'ui-state-default ui-corner-all ui-button btn-cancel'
            ));
            ?>
        </li>
    </ul>
</fieldset>
<?php $this->endWidget(); ?>

<div id="imageDialogContainer" style="display:none;"></div>